﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using BUS;

namespace GUI
{
    public partial class uc_ThongKeDT : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_ThongKeDT()
        {
            InitializeComponent();
        }
        DataTable tbl = new DataTable();
        SellGoodsBL sellgoods = new SellGoodsBL();
        private void gridPhieuBan_Click(object sender, EventArgs e)
        {
        }

        private void btnThongKe_Click(object sender, EventArgs e)
        {
            sellgoods.SellGoods_DeleteReport();
            int tongtien = 0;
            if (txtThang.Text != "")
            {

                String month = txtThang.DateTime.Month.ToString();
                String year = txtThang.DateTime.Year.ToString();
                gridTKDT.DataSource = sellgoods.SellGoods_SelectByDate(month,year);
                if (gridView1.RowCount != 0)
                {
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        tongtien += int.Parse(gridView1.GetRowCellValue(i, "TotalSellCost").ToString());
                    }
                    foreach (DTO.SellGoodsDTO sellreport in sellgoods.SellGoods_SelectByDate(month, year))
                    {
                        sellgoods.SellGoods_InsertReport(sellreport);

                    }
                }
               

            }
            
            txtTongTien.Text = tongtien.ToString();


        }

        private void btnInTK_Click(object sender, EventArgs e)
        {
            if (txtNgayLapTK.Text != "")
            {
                //rp_TKDT.thangtk = txtNgayLapTK.DateTime.Month.ToString();
                //rp_TKDT.ngaylap = txtNgayLapTK.Text;
                rp_TKDT rp = new rp_TKDT();
                ReportPrintTool printTool = new ReportPrintTool(rp);
                printTool.ShowPreviewDialog();
            }
            else
                MessageBox.Show("Vui lòng chọn ngày thống kê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }

        private void btnHuy_Click(object sender, System.EventArgs e)
        {


        }


    }
}
